package com.dididoctor.patient.Activity.Usercentre.Setting;

import android.content.Intent;
import android.view.View;

import com.dididoctor.patient.Activity.Login.loginActivity;
import com.dididoctor.patient.Activity.Usercentre.Setting.FeedBack.FeedBackActivity;
import com.dididoctor.patient.Bean.Token;
import com.dididoctor.patient.Dialog.CallPhoneDialog;
import com.dididoctor.patient.Dialog.LoginOutDialog;
import com.dididoctor.patient.MV.EduActivity;
import com.dididoctor.patient.R;
import com.dididoctor.patient.Utils.DataCleanManager;
import com.dididoctor.patient.Utils.LoaderImage;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.auth.AuthService;

/**
 * Created by Administrator on 2016/4/4.
 */
public class UserSettingActivity extends EduActivity {
    @Override
    public void init() {
        setText(R.id.tv_title, "设置与帮助");
        findViewById(R.id.rl_feedback).setOnClickListener(this);
        findViewById(R.id.rl_call).setOnClickListener(this);
        findViewById(R.id.rl_off).setOnClickListener(this);
        findViewById(R.id.btn_loginout).setOnClickListener(this);
    }

    @Override
    public void onClickEvent(View view) {
        switch (view.getId()) {
            case R.id.rl_feedback:
                Intent intent = new Intent(this, FeedBackActivity.class);
                startActivity(intent);
                break;
            case R.id.rl_call:
                CallPhoneDialog callPhoneDialog = new CallPhoneDialog(this, "4001129585");
                callPhoneDialog.show();
                break;
            case R.id.rl_off:
                Intent intent1 = new Intent(this, AboutActivity.class);
                startActivity(intent1);
                break;
            case R.id.btn_loginout:
                LoginOutDialog loginOutDialog = new LoginOutDialog(this, new LoginOutDialog.Outlogin() {
                    @Override
                    public void outlogin() {
                        loginoutok();
                    }
                });
                loginOutDialog.show();
                break;
        }
    }

    public void loginoutok() {
        DataCleanManager.cleanExternalCache(getApplicationContext());
        DataCleanManager.cleanInternalCache(getApplicationContext());
        NIMClient.getService(AuthService.class).logout();
        LoaderImage.clearCache();
        Token.logout();
        Intent intent = new Intent(this, loginActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
        finish();
    }

    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_user_setting);
    }
}
